package com.company.service.impl;

import com.company.entity.User;
import com.company.service.ISysUserService;

import java.io.*;
import java.security.Key;
import java.util.*;

public class SysUserServiceImpl implements ISysUserService {
    @Override
    public boolean login(int phone) {
        /*try {
            ObjectInputStream ois = new ObjectInputStream(new FileInputStream("/Users/l/Desktop/test.txt"));
            User user = (User)ois.readObject();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }*/
//        for (Integer integer : hashMap.keySet()) {
//            if (integer== phone){
//                return true;
//            }
//        }
        return false;
    }
    @Override
    public int register(User user,int phone) {
        if (hashMap.containsKey(phone)){
            return -1;
        }else{
            hashMap.put(phone,user);
            return 1;
        }
    }
//
//    public void write(){
//        try {
//            FileOutputStream fos = new FileOutputStream("/Users/l/Desktop/test.txt");
//            ObjectOutputStream oos = new ObjectOutputStream(fos);
//            oos.writeObject(hashMap);
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
}
